package shuashuami.hb.com.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

import shuashuami.hb.com.hbclient.R;
import shuashuami.hb.com.hdlibrary.glid.GlidUtil;
import shuashuami.hb.com.model.CdistriutionCenter;

/**
 * Created by Administrator on 2017/6/20.
 */

public class CdistriutionCenterAadpter extends BaseAdapter {
    private LayoutInflater inflater;
    private List<CdistriutionCenter> list;
    private Context con;

    private GlidUtil glidUtil;

    public CdistriutionCenterAadpter(List<CdistriutionCenter> list, Context context) {
        this.con = context;
        inflater = LayoutInflater.from(context);
        this.list = list;
        glidUtil = new GlidUtil(context);
    }

    @Override
    public int getCount() {
        if (null != list) {
            return list.size();
        } else {
            return 0;
        }
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        CdistriutionCenterViewHoler viewHolder;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.adatper_cdistriution_center_layout, null);
            viewHolder = new CdistriutionCenterViewHoler();
            viewHolder.imgHead = (ImageView) convertView.findViewById(R.id.img_cdistriution_center_head_image);
            viewHolder.tvNickName = (TextView) convertView.findViewById(R.id.tv_cdistriution_center_nick_name);
            viewHolder.tvID = (TextView) convertView.findViewById(R.id.tv_cdistriution_center_id_phone_num);
            viewHolder.tvDate = (TextView) convertView.findViewById(R.id.tv_cdistriution_center_date);
            viewHolder.tvMoney = (TextView) convertView.findViewById(R.id.tv_cdistriution_center_money);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (CdistriutionCenterViewHoler) convertView.getTag();
        }
        CdistriutionCenter content = list.get(position);
        glidUtil.uploadCircle(content.getImgHead(), viewHolder.imgHead, R.mipmap.ssm_icon_11);
        viewHolder.tvDate.setText(content.getDate());
        viewHolder.tvID.setText("ID:" + content.getId() + " " + content.getPhoneNum());
        viewHolder.tvNickName.setText(content.getNickName());
        viewHolder.tvMoney.setText("¥ " + content.getMoney());
        return convertView;
    }
    class CdistriutionCenterViewHoler {
        public ImageView imgHead;
        public TextView tvNickName;
        public TextView tvID;
        public TextView tvDate;
        public TextView tvMoney;
    }




}



